//
//  Combobox.m
//  FMS
//
//  Created by Steven on 10/12/13.
//  Copyright (c) 2013 QGSVN. All rights reserved.
//

#import "CustomButton.h"
#import <QuartzCore/QuartzCore.h>

@implementation CustomButton

- (void) awakeFromNib{
    self.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    self.layer.borderWidth = 0.5;
    [self setContentEdgeInsets:UIEdgeInsetsMake(0, 20, 0, 0)];
    [self setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    self.titleLabel.font = [UIFont fontWithName:FMS_REGULAR_FONT size:15];
    [self setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor whiteColor];
        self.layer.borderColor = [[UIColor lightGrayColor] CGColor];
        self.layer.borderWidth = 1;
        [self setContentEdgeInsets:UIEdgeInsetsMake(0, 20, 0, 0)];
        [self setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont fontWithName:FMS_REGULAR_FONT size:15];
        [self setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
//        self.titleLabel.textAlignment = UITextAlignmentLeft;
    }
    return self;
}
//add icon down
- (void)converCombobox{
    if (iconImage) {
        
        iconImage.frame = CGRectMake(self.frame.size.width - 23, 11, 13, 8);
    }
    else
    {
        iconImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width - 21, 11, 13, 8)];
        [self addSubview:iconImage];
    }
    self.layer.borderWidth = 1;
    self.userInteractionEnabled = YES;
    iconImage.image = [UIImage imageNamed:@"iconDropDown.png"];
}
- (void)converToLabel{
    self.layer.borderWidth = 0;
    self.userInteractionEnabled = NO;
    if (iconImage) {
        iconImage.hidden = YES;
    }
}
- (void)returnDefaultCustom{
    if (iconImage) {
        iconImage.hidden = NO;
    }
    self.layer.borderWidth = 1;
    self.userInteractionEnabled = YES;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
